<template>
  <view class="container">
    <view class="header">
      <text class="title">我的设备</text>
    </view>
    <view class="device-list">
      <view class="device-item" v-for="(device, index) in devices" :key="index">
        <image :src="device.icon" class="device-icon" />
        <text class="device-name">{{ device.name }}</text>
        <text class="device-id">{{ device.id }}</text>
        <button @click="viewDeviceDetails(device.id)">查看详情</button>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      devices: [
        { id: 1, name: '设备1', icon: '/static/device1.png' },
        { id: 2, name: '设备2', icon: '/static/device2.png' },
        // 可以添加更多设备
      ]
    };
  },
  methods: {
    viewDeviceDetails(id) {
      // 跳转到设备详情页面，这里使用id作为示例
      uni.navigateTo({
        url: `/pages/device-details/device-details?id=${id}`
      });
    }
  }
};
</script>
<style scoped>
.container {
  padding: 10px;
  background-color: #f8f8f8;
}
.header {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 10px;
}
.title {
  font-size: 20px;
  font-weight: bold;
}
.device-list {
  display: flex;
  flex-direction: column;
}
.device-item {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
  padding: 10px;
  border: 1px solid #e0e0e0;
  border-radius: 5px;
  background-color: #ffffff;
}
.device-icon {
  width: 50px;
  height: 50px;
  margin-right: 10px;
}
.device-name {
  font-size: 16px;
  font-weight: bold;
}
.device-id {
  font-size: 12px;
  color: #999;
  margin-left: auto;
}
button {
  background-color: #007aff;
  color: white;
  border: none;
  border-radius: 5px;
  padding: 5px 10px;
}
</style>